const app = getApp();
const db = wx.cloud.database().collection("actor")
Page({
  data: {
    equipmentDetail: {}
  },
  onLoad: function(options) {
    const equipmentId = options.id;
    this.getEquipmentDetail(equipmentId);
  },
  getEquipmentDetail: function(id) {
    db.doc(id).get().then(res => {
      console.log(res.data);
      // Check if the link property exists and is not undefined
      if (res.data.link) {
        // Split the link string by newline character ('\n') into an array
        res.data.linkArray = res.data.link.split('\n');
      } else {
        // If the link property is undefined, set an empty array for linkArray
        res.data.linkArray = [];
      }
      this.setData({
        equipmentDetail: res.data
      });
    }).catch(err => {
      console.error(err);
    });
  }
  
});
